lst = [90, 89, 28, 20, 99, 78, 98]



def sort(lst):
    # 冒泡排序
    for i in range(len(lst)):
        for j in range(len(lst)-i-1):
            if lst[j] > lst[j+1]:
                lst[j], lst[j+1]=lst[j+1], lst[j]
    print(lst)


def xz(lst):
    # 选择排序
    for i in range(len(lst)-1):
        index=i
        for j in range(i+1,len(lst)):
            if lst[j]<lst[index]:
                index=j
        lst[index],lst[i]=lst[i],lst[index]
    return lst


a=xz(lst)
print(a)

# sort(lst)

def cr(lst):
    for i in range(1, len(lst)):
        index = i-1
        a = lst[i]
        while lst[index] > a:
            lst[index+1] = lst[index]
            index = index-1
        lst[index+1] = a
    return lst

def cr1(lst):
    """插入排序"""
    for i in range(1, len(lst)):
        index = i
        for j in range(i-1, -1, -1):
            if lst[j] < lst[i]:
                index = j+1
                break
        if index != i:
            lst[i], lst[index] = lst[index], lst[i]

    return lst
x=cr1(lst)
print(x)


